/* Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef __MCTP_TRANSFER_H__
#define __MCTP_TRANSFER_H__

#include "transfer/msg_transfer.h"

class MctpTransfer : public MsgTransfer
{
public:
    MctpTransfer(const string& device_name) : MsgTransfer(device_name) {};

    uint32_t msgMaxSize    = MAX_SPDM_MSG_SIZE;
    uint32_t msgHeaderSize = TRANSPORT_HEADER_SIZE;
    uint32_t msgTailSize   = TRANSPORT_TAIL_SIZE;

    uint32_t EncodeMessage(void *spdm_context, const uint32_t *session_id, bool is_app_message,
        bool is_request_message, size_t message_size, void *message, size_t *transport_message_size,
        void **transport_message) override;
    uint32_t DecodeMessage(void *spdm_context, uint32_t **session_id, bool *is_app_message,
        bool is_request_message, size_t transport_message_size, void *transport_message, size_t *message_size,
        void **message) override;
    uint32_t DeviceSendMessage(void *spdm_context, size_t message_size, const void *message,
        uint64_t timeout) override;
    uint32_t DeviceReceiveMessage(void *spdm_context, size_t *message_size, void **message,
        uint64_t timeout) override;
    uint32_t AcquireSenderBuffer(void *spdm_context, void **msg_buf_ptr) override;
    void ReleaseSenderBuffer(void *spdm_context, const void *msg_buf_ptr) override;
    uint32_t AcquireReceiverBuffer(void *spdm_context, void **msg_buf_ptr) override;
    void ReleaseReceiverBuffer(void *spdm_context, const void *msg_buf_ptr) override;

    int32_t RegisterFunctions(void *spdm_context) override;
};

#endif // __MCTP_TRANSFER_H__